package com.bj.zspace.bytebuddy.bbtest;

import com.bj.zspace.bytebuddy.normal_test.Service;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.NamingStrategy;
import net.bytebuddy.dynamic.DynamicType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;

/**
 * redefine类
 **/
public class GenerateRedefineClass {
    public static final Logger log = LoggerFactory.getLogger(GenerateRedefineClass.class);

    public static void main(String[] args) throws IOException {

        String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();

        DynamicType.Unloaded<Service> unloaded =
            new ByteBuddy().with(new NamingStrategy.SuffixingRandom("ByteBuddyClass")).redefine(Service.class).make();

        unloaded.saveIn(new File(path));

    }

}
